﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using BUS;

namespace MasterPageGroupF3
{
    public partial class DangNhapHCM : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btThanVienDangNhap_Click(object sender, EventArgs e)
        {
            String email = txtThanhVienLogEmail.Text;
            if (MEMBERBUS.TonTai_Email(email) == true)
            {
                MEMBER temp = MEMBERBUS.LayMemberCoEmail(email);
                if (temp.PASSWORD.Equals(txtThanhVienLogMatKhau.Text))
                {
                    Session["UserName"] = txtThanhVienLogEmail.Text;
                    Response.Redirect("~/ho-chi-minh/index.aspx");
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('Bạn nhập Email hoặc mật khẩu sai.');</script>");
                }
                //Response.Redirect("~/ho-chi-minh/index.aspx?UserName="+txtThanhVienLogEmail.Text);
            }
            else
            {
                Response.Write("<script language='javascript'>alert('Bạn nhập Email hoặc mật khẩu sai.');</script>");
            }
        }

        protected void btnCungCapDangNhap_Click(object sender, EventArgs e)
        {
            String user = txtCungCapLogEmail.Text;
            if (PROVIDERBUS.TonTai_User(user) == true)
            {
                PROVIDER temp = PROVIDERBUS.LayProviderCoUser(user);
                if (temp.PASSWORD.Equals(txtCungCapLogMatKhau.Text))
                {
                    Session["Provider"] = user;
                    Response.Redirect("~/ho-chi-minh/index.aspx");
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('Bạn nhập User hoặc mật khẩu sai.');</script>");
                }
                //Response.Redirect("~/ho-chi-minh/index.aspx?UserName="+txtThanhVienLogEmail.Text);
            }
            else
            {
                Response.Write("<script language='javascript'>alert('Bạn nhập User hoặc mật khẩu sai.');</script>");
            }
        }
    }
}